package com.jvyou.pms.controller;



import com.jvyou.common.response.R;
import com.jvyou.pms.domain.dto.JhyJhyzdxxDto;
import com.jvyou.pms.domain.entity.JhyJhyzdxx;
import com.jvyou.pms.service.JhyJhyzdxxService;
import org.springframework.web.bind.annotation.*;
import lombok.RequiredArgsConstructor;
import cn.dev33.satoken.annotation.SaCheckPermission;
import java.util.List;
import com.jvyou.common.response.BizResponseCode;
import com.jvyou.common.exception.BizException;
import com.jvyou.common.response.Page;


/**
 * (JhyJhyzdxx)表控制层
 *
 * @author 橘柚
 * @since 2025-06-29 01:20:30
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/jhyJhyzdxx")
public class JhyJhyzdxxController  {
    
    private final JhyJhyzdxxService jhyJhyzdxxService;
    
     /**
     * 查询jhyJhyzdxx列表
     *
     * @param dto 查询参数
     * @return jhyJhyzdxx 列表
     */
    @GetMapping("/list")
    @SaCheckPermission("sys:jhyJhyzdxx:list")
    public R<List<JhyJhyzdxx>> list(@ModelAttribute JhyJhyzdxxDto dto) {
        return R.ok(jhyJhyzdxxService.listJhyJhyzdxx(dto));
    }

     /**
     * 分页查询jhyJhyzdxx列表
     *
     * @param dto 查询参数
     * @return jhyJhyzdxx 分页列表
     */
    @GetMapping("/page")
    @SaCheckPermission("sys:jhyJhyzdxx:page")
    public R<Page<JhyJhyzdxx>> page(@ModelAttribute JhyJhyzdxxDto dto) {
        return R.ok(jhyJhyzdxxService.pageJhyJhyzdxx(dto));
    }

    /**
     * 通过主键查询 jhyJhyzdxx 单条
     *
     * @param id jhyJhyzdxx 主键
     * @return jhyJhyzdxx 单条数据
     */
    @GetMapping("/{id}")
    @SaCheckPermission("sys:jhyJhyzdxx:get")
    public R<JhyJhyzdxx> selectOne(@PathVariable("id") Long id) {
        return R.ok(jhyJhyzdxxService.getById(id));
    }

    /**
     * 新增 jhyJhyzdxx
     *
     * @param jhyJhyzdxx 实体对象
     * @return 新增jhyJhyzdxx结果
     */
    @PostMapping
    @SaCheckPermission("sys:jhyJhyzdxx:insert")
    public R<JhyJhyzdxx> insert(@RequestBody JhyJhyzdxx jhyJhyzdxx) {
        boolean success = jhyJhyzdxxService.save(jhyJhyzdxx);
        if (!success) {  
		    throw new BizException(BizResponseCode.ERR_12001);  
		}  
		return R.ok(jhyJhyzdxx);
    }

    
     /**
     * 修改jhyJhyzdxx
     *
     * @param jhyJhyzdxx 实体对象
     * @return 修改jhyJhyzdxx结果
     */
    @PutMapping("/updateById")
    @SaCheckPermission("sys:jhyJhyzdxx:update")
    public R<JhyJhyzdxx> updateById(@RequestBody JhyJhyzdxx jhyJhyzdxx) {
        boolean success = jhyJhyzdxxService.updateById(jhyJhyzdxx);
        if (!success) {  
		    throw new BizException(BizResponseCode.ERR_12003);  
		}
		return R.ok(jhyJhyzdxx);
    }
    

    /**
     * 删除jhyJhyzdxx数据
     *
     * @param id jhyJhyzdxx主键
     * @return 删除jhyJhyzdxx结果
     */
    @DeleteMapping("/{id}")
    @SaCheckPermission("sys:jhyJhyzdxx:delete")
    public R<Boolean> delete(@PathVariable("id") Long id) {
        boolean success = jhyJhyzdxxService.removeById(id);
		if (!success) {  
		    throw new BizException(BizResponseCode.ERR_12002);  
		}  
		return R.ok(Boolean.TRUE);
    }
    
}

